import moment from 'dayjs';
import send from '../config/MailConfig';
class loginController{
  //重置密码的接口
  async forget (ctx) {
    const { body } = ctx.request
    console.log(body.username);
    //发送邮件
    const result = await send({
      type: 'reset',
      code: body.code,//可有可无，主要是判断显示修改密码还是邮箱
      data: {
        // key:key,这里是一个唯一标识，相当于一个token
        username:body.username
      },
      expire: moment()
            .add(30, 'minutes')
        .format('YYYY-MM-DD HH:mm:ss'),//过期时间
      email: body.username,//修改密码的邮箱，就是往哪个邮箱发信息
      user: body.username//测试用，完整写法：user.name ? user.name : body.username
    })
    ctx.body = {
      code: 200,
      data:result
    }
 
}
}
export default new loginController()